package com.chenqq.qsocket.handler;

import com.chenqq.qsocket.listener.SocketMessageListener;
import com.chenqq.qsocket.message.KeepAliveMessage;
import com.chenqq.qsocket.message.RequestSendFileMessage;
import com.chenqq.qsocket.message.SocketMessage;
import com.chenqq.qsocket.message.TextMessage;
import com.chenqq.qsocket.tools.LogShow;

import org.apache.mina.core.session.IoSession;
import org.json.JSONException;

public class AliveMessageHandler implements MessageHandler {
    private SocketMessageListener listener;
    private String tag;

    @Override
    public void handleMessage(SocketMessage msg, IoSession session) throws JSONException {
        KeepAliveMessage requestSendFileMessage = new KeepAliveMessage(msg);
        byte type = requestSendFileMessage.getType();
        String body = requestSendFileMessage.getJSONBody();
        LogShow.showV("心跳包处理 "+type+ " byte "+body);
        session.write(requestSendFileMessage);


    }

    @Override
    public void handleListener(String tag, SocketMessageListener listener) {
      this.listener=listener;
      this.tag=tag;
    }
}
